using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ACME.Northwind.DataTransfer;
using System.Linq.Expressions;
using ACME.Northwind.Service.Interfaces;

namespace ACME.Northwind.WCFProxy
{
	/// <summary>
	/// The service implementation for CustomerCustomerDemo object
	/// </summary>
	public partial class CustomerCustomerDemoService : ICustomerCustomerDemoService
	{
		#region ICustomerCustomerDemoService Members

		/// <summary>
		/// Run a selection by the primary key
		/// </summary>
		public CustomerCustomerDemoDTO SelectByPrimaryKey(string customerid, string customertypeid)
		{
			return DataService.Instance.GetCustomerCustomerDemo(customerid, customertypeid);
		}

		/// <summary>
		/// Run the persist for a list
		/// </summary>
		public bool Persist(List<CustomerCustomerDemoDTO> list)
		{
			bool retval = true;
			foreach (CustomerCustomerDemoDTO customercustomerdemo in list)
			{
				retval &= this.Persist(customercustomerdemo);
			}
			return retval;
		}

		/// <summary>
		/// Run the persist for an object
		/// </summary>
		public bool Persist(CustomerCustomerDemoDTO dto)
		{
			return (DataService.Instance.PersistCustomerCustomerDemo(dto) != null);
		}

		/// <summary>
		/// Run a selection using LINQ
		/// </summary>
		public List<CustomerCustomerDemoDTO> RunSelect(string linq)
		{
			List<CustomerCustomerDemoDTO> retVal = new List<CustomerCustomerDemoDTO>();
			retVal.AddRange(DataService.Instance.GetCustomerCustomerDemoListByLINQ(linq));
			return retVal;
		}

		/// <summary>
		/// Run a paginated selection using LINQ
		/// </summary>
		public PagedQueryResults<CustomerCustomerDemoDTO> RunSelect(int pageIndex, int pageSize, bool ascending, string sortColumn, string linq)
		{
			return DataService.Instance.GetCustomerCustomerDemoListPaged(pageIndex, pageSize, ascending, sortColumn, linq);
		}

		/// <summary>
		/// Run a selection for all objects
		/// </summary>
		public List<CustomerCustomerDemoDTO> RunSelect()
		{
			List<CustomerCustomerDemoDTO> retVal = new List<CustomerCustomerDemoDTO>();
			DataServiceClient ds = DataService.Instance;
			retVal.AddRange(ds.GetCustomerCustomerDemoList());
			return retVal;
		}

		/// <summary>
		/// Return the related CustomerDemographic item
		/// </summary>
		public CustomerDemographicDTO GetCustomerDemographicItem(CustomerCustomerDemoDTO item)
		{
			CustomerDemographicDTO retval = new CustomerDemographicDTO();
			DataServiceClient ds = DataService.Instance;
			retval = ds.GetCustomerDemographic(item.CustomerTypeId);
			return retval;
		}

		/// <summary>
		/// Return the related Customer item
		/// </summary>
		public CustomerDTO GetCustomerItem(CustomerCustomerDemoDTO item)
		{
			CustomerDTO retval = new CustomerDTO();
			DataServiceClient ds = DataService.Instance;
			retval = ds.GetCustomer(item.CustomerId);
			return retval;
		}

		/// <summary>
		/// Delete the specified item
		/// </summary>
		public bool Delete(CustomerCustomerDemoDTO item)
		{
			DataServiceClient ds = DataService.Instance;
			return ds.DeleteCustomerCustomerDemo(item);
		}

		#endregion
	}
}
